package com.kedacom.ctsp.authz.oauth2.client;

import com.kedacom.ctsp.authz.oauth2.client.provider.RequestClientFilter;
import com.kedacom.ctsp.authz.oauth2.client.provider.RequestLoginUrlFilter;
import com.kedacom.ctsp.authz.oauth2.client.provider.RestLogoutHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.authentication.logout.LogoutHandler;

/**
 * OAuth2自动配置类
 *
 * @author xuwei
 * @create 2018-05-10 15:42
 **/
@Configuration
@EnableFeignClients("com.kedacom.ctsp.authz.oauth2.client.service")
public class OAuth2ClientAutoConfiguration {

    /**
     * @return 登出
     */
    @Bean
    @ConditionalOnMissingBean(LogoutHandler.class)
    public RestLogoutHandler restLogoutHandler() {
        return new RestLogoutHandler();
    }

    @Bean
    @ConditionalOnMissingBean
    public RequestClientFilter requestClientFilter() {
        return new RequestClientFilter();
    }

    @Bean
    @ConditionalOnMissingBean
    public RequestLoginUrlFilter RequestLoginUrlFilter() {
        return new RequestLoginUrlFilter();
    }
}
